//
//  ViewController.m
//  jisuanqi
//
//  Created by mac on 16-3-1.
//  Copyright (c) 2016年 yinbin. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

-(IBAction)met{
    
    /*
     NSString *text1 = self.textFeild1.text;
     NSString *text2 = self.textFeild2.text;
     int num1 = [text1 intValue];
     int num2 = [text2 intValue];
     int result = 0;
     result = num1 - num2;
     
     NSString *output = [NSString stringWithFormat:@"%d",result];
     
     self.res.text = output;
     NSLog(@"➖减号按钮被点击了");
     NSLog(@"%@",text1);
     NSLog(@"%@",text2);
     NSLog(@"%d",result);
     */
    
    NSString *text1 = self.textField1.text;
    NSString *text2 = self.textField2.text;
    
    int num1 = [text1 intValue];
    int num2 = [text2 intValue];
    int result = 0;

    NSString * yunsuanfu = self.pls.text;
    char ch = [yunsuanfu characterAtIndex:0];
    //char ch = [self.pls.text characterAtIndex:0];
    switch (ch) {
        case '+':
            result = num1 + num2;
            break;
        case '-':
            result = num1 - num2;
            break;
        case '*':
            result = num1 * num2;
            break;
        case '/':
            result = num1 / num2;
            break;
        default:
            break;
    }
    NSLog(@"%d",result);
    NSString *output = [NSString stringWithFormat:@"%d",result];
    self.res.text = output;
    [self.view endEditing:YES];
    
}

-(IBAction)jia{
    self.pls.text = @"+";
}

-(IBAction)jian{
    self.pls.text = @"-";
}

-(IBAction)chen{
    self.pls.text = @"*";
}

-(IBAction)chu{
    self.pls.text = @"/";
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
